<template>
  <t-tabs v-model="value" size="medium">
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="1" label="项目信息表">
      <t-form labelAlign="top" ref="form" :data="data" class="step-form table-form">
        <t-row>
          <t-col :span="2" class="title">项目编号</t-col>
          <t-col :span="4">
            {{ projectData.projectNum }}
          </t-col>
          <t-col :span="2" class="title"><span class="require">*</span>项目名称</t-col>
          <t-col :span="4">
            <t-form-item label="项目名称：" name="projectName">
              {{ data.projectName }}
            </t-form-item>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title"><span class="require">*</span>密 级</t-col>
          <t-col :span="4">
            <t-form-item name="secretLevel">
              <t-radio-group :disabled="true" v-model="data.secretLevel"
                :options="dict.type.secret_level"></t-radio-group>
            </t-form-item>
          </t-col>
          <t-col :span="2" class="title">参加单位总数</t-col>
          <t-col :span="4">{{ data.projectCompanyList.length }}个</t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title" style="flex-direction: column">项目承担单位
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-row>
              <t-col :span="2" class="title">名 称</t-col>
              <t-col :span="10">{{ data.declareDeptName }}</t-col>
            </t-row>
            <t-row>
              <t-col :span="2" class="title"><span class="require">*</span>单位所在地</t-col>
              <t-col :span="10">
                <t-form-item name="locationId">
                  {{ data.locationId | filterParentsByTree(locationOptions) }}
                </t-form-item>
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="2" class="title"><span class="require">*</span>通讯地址</t-col>
              <t-col :span="4">
                <t-form-item name="address">
                  {{ data.address }}
                </t-form-item>
              </t-col>
              <t-col :span="2" class="title"><span class="require">*</span>邮编</t-col>
              <t-col :span="4">
                <t-form-item name="postCode">
                  {{ data.postCode }}
                </t-form-item>
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="2" class="title"><span class="require">*</span>单位性质</t-col>
              <t-col :span="10">
                <t-form-item name="assumeCompanyType">
                  <t-radio-group :disabled="true" v-model="data.assumeCompanyType"
                    :options="dict.type.assume_company_type"></t-radio-group>
                </t-form-item>
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="2" class="title">归口管理单位</t-col>
              <t-col :span="10">{{ data.managerDeptName }}</t-col>
            </t-row>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">合作或协作单位
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-row>
              <t-col :span="1" class="title">序号</t-col>
              <t-col :span="11" class="title">单位名称</t-col>
            </t-row>
            <t-row v-for="(item, index) in data.projectCompanyList.filter(val => { return val.type === '2' })"
              :key="index">
              <t-col :span="1" style="justify-content: center">{{ index + 1 }}</t-col>
              <t-col :span="11">{{ item.name }}</t-col>
            </t-row>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">项目负责人
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-row>
              <t-col :span="1" class="title">姓名</t-col>
              <t-col :span="3">{{ projectData.projectLeader.name }}</t-col>
              <t-col :span="1" class="title">性别</t-col>
              <t-col :span="3">{{ projectData.projectLeader.sex | filterByDict(dict.type.sys_user_sex) }}</t-col>
              <t-col :span="1" class="title">出生年月</t-col>
              <t-col :span="3">{{ projectData.projectLeader.birthDate }}</t-col>
            </t-row>
            <t-row>
              <t-col :span="1" class="title">学历</t-col>
              <t-col :span="11">
                {{ projectData.projectLeader.education | filterByDict(dict.type.education) }}
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="1" class="title">职称</t-col>
              <t-col :span="11">
                {{ projectData.projectLeader.profTit | filterByDict(dict.type.prof_tit) }}
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="1" class="title">专业</t-col>
              <t-col :span="3">
                {{ projectData.projectLeader.majorNowName }}
              </t-col>
              <t-col :span="1" class="title">联系电话</t-col>
              <t-col :span="3">{{ projectData.projectLeader.phone }}</t-col>
              <t-col :span="1" class="title">邮箱</t-col>
              <t-col :span="3">{{ projectData.projectLeader.email }}</t-col>
            </t-row>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">研究人员人数
          </t-col>
          <t-col :span="10" style="display:block;">
            共 {{ data?.projectTeam?.totalCount }} 人。其中： 高级： {{ data?.projectTeam?.highCount }} 人 中级：
            {{ data?.projectTeam?.middleCount }} 人 初级： {{ data?.projectTeam?.primaryCount }} 人 其他：
            {{ data?.projectTeam?.auxilian }} 人
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">起止时间
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-row>
              <t-col :span="2" class="title"><span class="require">*</span>开始时间</t-col>
              <t-col :span="4">
                <t-form-item name="startDate">
                  {{ data.startDate }}
                </t-form-item>
              </t-col>
              <t-col :span="2" class="title"><span class="require">*</span>完成时间</t-col>
              <t-col :span="4">
                <t-form-item name="completeDate">
                  {{ data.completeDate }}
                </t-form-item>
              </t-col>
            </t-row>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">项目类型
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-radio-group v-model="projectData.projectCategory" :disabled="true"
              :options="categoryOptions"></t-radio-group>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title"><span class="require">*</span>所属技术领域
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-form-item name="technosphere">
              <t-radio-group :disabled="true" v-model="data.technosphere"
                :options="dict.type.subject_classification"></t-radio-group>
            </t-form-item>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title"><span class="require">*</span>项目技术来源
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-form-item name="technologySource">
              <t-radio-group :disabled="true" v-model="data.technologySource"
                :options="dict.type.technology_source"></t-radio-group>
            </t-form-item>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title"><span class="require">*</span>主要研究内容(100字以内)
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-form-item name="mainContent">
              {{ data.mainContent }}
            </t-form-item>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title"><span class="require">*</span>预期成果
          </t-col>
          <t-col :span="10" class="sub-col">
            <t-row>
              <t-col :span="1" class="title">科技奖励</t-col>
              <t-col :span="11" class="sub-col">
                <t-row>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">国家级</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.awardsGjCount">
                          {{ data.contractExpectResults.awardsGjCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">省部级</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.awardsSbCount">
                          {{ data.contractExpectResults.awardsSbCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col class="sub-title text-center" :flex="1">专著/论文</t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">中文核心论文</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.cnThesisCount">
                          {{ data.contractExpectResults.cnThesisCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">SCI论文</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.sciThesisCount">
                          {{ data.contractExpectResults.sciThesisCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">EI论文</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.eiThesisCount">
                          {{ data.contractExpectResults.eiThesisCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">ISTP论文</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.istpThesisCount">
                          {{ data.contractExpectResults.istpThesisCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">专著</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.treatiseCount">
                          {{ data.contractExpectResults.treatiseCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">国际学术奖</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.academicCount">
                          {{ data.contractExpectResults.academicCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                </t-row>
              </t-col>
            </t-row>
            <t-row>
              <t-col :span="1" class="title">成果转化</t-col>
              <t-col :span="11" class="sub-col">
                <t-row>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">中试</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.pilotCount">
                          {{ data.contractExpectResults.pilotCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">规模化生产</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.scaleCount">
                          {{ data.contractExpectResults.scaleCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col class="sub-title text-center" :flex="1">专利</t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">发明专利</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.patentFmCount">
                          {{ data.contractExpectResults.patentFmCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">实用新型专利</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.patentSyCount">
                          {{ data.contractExpectResults.patentSyCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">其他</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.otherCount">
                          {{ data.contractExpectResults.otherCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                  <t-col style="flex-direction: column;padding: 0 !important; border: 0;" :flex="1">
                    <t-row>
                      <t-col :span="12" class="sub-title text-center">标准制（修）定</t-col>
                    </t-row>
                    <t-row>
                      <t-col :span="12">
                        <t-form-item name="contractExpectResults.standardCount">
                          {{ data.contractExpectResults.standardCount }}
                        </t-form-item>
                      </t-col>
                    </t-row>
                  </t-col>
                </t-row>
              </t-col>
            </t-row>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">经费投入
          </t-col>
          <t-col :span="10" style="display:block;">
            <t-row>
              <t-col :span="2" class="title"><span class="require">*</span>总经费</t-col>
              <t-col :span="4"> <t-form-item name="adviceFunding">
                  {{ data.adviceFunding }}万元
                </t-form-item></t-col>
              <t-col :span="2" class="title"><span class="require">*</span>{{ site_tag === 'jtt' ? '厅拨经费' : '集团补助经费'
                }}</t-col>
              <t-col :span="4"> <t-form-item name="subsidyFunding">
                  {{ data.subsidyFunding }}万元
                </t-form-item></t-col>
            </t-row>
          </t-col>
        </t-row>
      </t-form>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="2" label="项目概况">
      <t-form ref="form" :colon="true" labelAlign="top">
        <t-row>
          <t-col :span="12">
            <t-card class="step-card" size="small" title="1.立项依据、研究内容、目标以及拟解决的关键科学问题（限1000字）">
              <t-form-item name="baseContent">
                <inner-html :content="data.contractOverview.baseContent"></inner-html>
              </t-form-item>
            </t-card>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="12">
            <t-card class="step-card" size="small" title="2.拟采取的研究方案及可行性分析、本项目的特色与创新之处（限1000字）">
              <t-form-item name="approach">
                <inner-html :content="data.contractOverview.approach"></inner-html>
              </t-form-item>
            </t-card>
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="12">
            <t-card class="step-card" size="small" title="3.预期研究结果及表达形式（限500字）">
              <t-form-item name="achievement">
                <inner-html :content="data.contractOverview.achievement"></inner-html>
              </t-form-item>
            </t-card>
          </t-col>
        </t-row>
      </t-form>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="3" label="项目经费预算">
      <t-alert style="margin-bottom: 14px" theme="info" title="填表说明：">
        <div slot="message">
          <p class="span-txt">
            1.项目申报时，只需填列项目经费来源和支出的预算数；在项目结题验收时，项目经费来源和支出的预算和决算数均需埴列。
          </p>
          <p>2.“其他”一栏是在与上几栏内容均不相同时具体填写。</p>
          <p>3.直接费用</p>
          <p>（1）设备费： 是指在项目研究开发过程中购置或试制专用仪器设备，对现有仪器设备 进行升级改造， 以及租赁外单位仪器设备而发生的费用。厅拨经费要严格控制设备购置费支出。</p>
          <p>
            （2）业务费：是指在项目实施过程中消耗的各种材料、辅助材料等低值易耗品的采购、运输、装卸、整理等费用，发生的测试化验加工、燃料动力、出版/文献/信息传播/知识产权事务、会议/差旅/国际合作交流等费用，以及其他相关支出。
          </p>
          <p>（3）劳务费： 是指在项目实施过程中支付给参与项目的研究生、博士后、访问学者和项目聘用的研究人员、科研辅助人员等的劳务性费用，以及支付给临时聘请的咨询专家的费用等。</p>
          <p>4.间接费用</p>
          <p>间接费用总额使用分段超额累退比例法计算和控制，按照不超过直接费用扣除设备购置费后的一定比例核定，具体比例如下：500万元及以下部分不超过30％；超过500万元至1000 万元的部分不超过25％；
            超过1000万元的部分不超过20％。</p>
          <p>（1）管理费：是指在项目研究开发过程中对使用本单位现有仪器设备及房屋，日常水、电、气、暖消耗，以及其他有关管理费用的补助支出。</p>
          <p>（2）绩效支出：是指承担项目研究任务的单位为提高科研工作绩效安排的相关支出。有财政拨款补助的单位安排的绩效支出不得超过直接费用扣除设备购置费后的5％。</p>
        </div>
      </t-alert>
      <project-budget v-model="data.projectBudget" :projectId="projectData.id" phaseType="3"></project-budget>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="4" label="项目进度">
      <project-research-plan ref="project-research-plan" v-model="data.researchPlanList" :projectId="projectData.id"
        phaseType="3"></project-research-plan>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="5" label="项目绩效目标">
      <project-kpi phaseType="3" :projectId="projectData.id" ref="project-kpi"
        v-model="data.expectResultsList"></project-kpi>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="6" label="成果及其形成的知识产权的归属与保护">
      <t-alert style="margin-bottom: 14px" theme="info" title="填写说明：">
        <div slot="message">
          <p class="span-txt">
            本项目科技成果及其形成的知识产权，其归属、管理和使用按照《交通运输行业知识产权管理办法》的有关规定执行。</p>
          <p class="span-txt">
            （其他约定）
          </p>
        </div>
      </t-alert>
      <t-form ref="form" :colon="true" labelAlign="top">
        <t-row>
          <t-col :span="12">
            <t-card class="step-card" size="small" title="成果及其形成的知识产权的归属与保护">
              <t-form-item name="content">
                <inner-html :content="data.contractResults.content"></inner-html>
              </t-form-item>
            </t-card>
          </t-col>
        </t-row>
      </t-form>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="7" label="单位信息">
      <t-row>
        <t-col :span="12">
          <project-unit ref="project-unit" v-model="data.projectCompanyList" :projectId="projectData.id"
            phaseType="3"></project-unit>
        </t-col>
      </t-row>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="8" label="研究人员">
      <t-alert style="margin-bottom: 14px" theme="info" title="填表说明：">
        <div slot="message">
          <p class="span-txt">
            1.青年科技人员数量占比不低于10%；
          </p>
          <p>2.职业教育改革专项、青年科技项目原则上项目负责人应为1名。</p>
          <p>3.青年人员，具有博士学位，年龄在40周岁以下；具有硕士学位、年龄在35周岁以下，女性年龄可适当放宽2周岁，以上年龄截至申报时间上一年度年底。</p>
        </div>
      </t-alert>
      <project-member :show-tip="true" v-model="data.projectMemberList" :projectId="projectData.id"
        phaseType="3"></project-member>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="9" label="共同条款">
      <t-row>
        <t-col :span="12">
          <t-alert v-if="site_tag === 'jtt'" style="margin-bottom: 14px" theme="info" title="固定条款：">
            <div slot="message">
              <p class="span-txt">
                任务书（合同）各方共同遵守《江西省交通运输厅科技项目管理办法》（以下简称《办法》）。</p>
              <p class="span-txt">1．项目承担方（乙方）必须按要求报告项目年度执行情况。</p>
              <p class="span-txt">
                2．项目执行过程中，承担方（乙方）如需调整任务，应根据《办法》中有关规定，向委托方（甲方）提出变更内容及说明的申请报告，经委托方（甲方）审定批准后实施。未接到正式批准书以前，双方应按任务书（合同）履行，否则后果由自行调整的一方负责。
              </p>
              <p class="span-txt">
                3．项目承担方（乙方）因某种原因（如与研究内容有出入、挪用经费、技术措施或实施条件不落实等）致使项目无法执行而要求终止任务，委托方（甲方）可根据调查结果终止研究任务。</p>
              <p class="span-txt">4．项目承担方（乙方）承担项目研究费用按国家科技经费使用管理的相关规定合理开支。</p>
              <p class="span-txt">5．委托方（甲方）根据科技经费的财务管理制度的规定，监督经费的使用情况。</p>
              <p class="span-txt">6．项目执行过程中，委托方（甲方）提出变更任务书（合同）有关内容时，要与承担方（乙方）协商达成书面协议。</p>
              <p class="span-txt">7．本任务书（合同）签订各方均负有相应的责任。若有争议或纠纷时，按科技项目有关管理办法有关条款处理。</p>
              <p class="span-txt">8．任务书（合同）正式文本各方签章后上传厅管理系统留存备查。</p>
            </div>
          </t-alert>
          <t-alert v-else style="margin-bottom: 14px" theme="info" title="固定条款：">
            <div slot="message">
              <p class="span-txt">
                任务书（合同）各方共同遵守《江西省交通投资集团有限责任公司科技创新管理办法》（以下简称《办法》）。</p>
              <p class="span-txt">1．项目承担方（乙方）必须按要求报告项目年度执行情况、下一年度经费预算和有关统计报表，逾期不报，委托方（甲方）有权暂停拨款。</p>
              <p class="span-txt">
                2．项目执行过程中，承担方（乙方）如需调整任务，应根据《办法》中有关规定，向委托方（甲方）提出变更内容及说明的申请报告，经委托方（甲方）审定批准后实施。未接到正式批复以前，双方须按原任务书（合同）履行，否则后果由自行调整的一方负责。
              </p>
              <p class="span-txt">3. 项目承担方（乙方）因某种原因（如与研究内容有出入、挪用经费、技术措施或实施条件不落实等）致使项目无法执行而要求中止任务，委托方（甲方）可根据调查结果中止研究任务。
              </p>
              <p class="span-txt">4．项目承担方（乙方）承担项目所需拨款按国家科技经费使用范围开支。</p>
              <p class="span-txt">5．委托方（甲方）根据科技经费的财务管理制度的规定，监督经费的使用情况。</p>
              <p class="span-txt">6．项目执行过程中，委托方（甲方）提出变更任务书（合同）有关内容时，要与承担方（乙方）协商达成书面协议。</p>
              <p class="span-txt">7．本任务书（合同）签订各方均负有相应的责任。若有争议或纠纷时，按科技项目有关管理办法有关条款处理。</p>
              <p class="span-txt">8．任务书（合同）正式文本委托方（甲方）和第一承担单位（乙方）各存两份、各承担单位和保证方各存一份。</p>
            </div>
          </t-alert>
          <t-card class="step-card" size="small" title="本任务书（合同）所协议的其他条款如下：">
            <t-form labelAlign="top" ref="form" class="step-form" labelWidth="140px">
              <t-form-item name="terms">
                <contract-terms ref="contract-terms" v-model="data.contractTerms" :projectId="projectData.id"
                  phaseType="3"></contract-terms>
              </t-form-item>
            </t-form>
          </t-card>

        </t-col>
      </t-row>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="10" label="按专家评审意见修改说明">
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <approve-list-by-review-type
            :review-type="![1662099020236, 1660720633654].includes(projectData.projectCategory) ? '4' : '5'"
            :obj-id="projectData.id"></approve-list-by-review-type>
        </t-col>
      </t-row>
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <t-card class="step-card" size="small">
            <template #title>
              按专家评审意见修改说明：<span style="color: red">必须参照专家意见逐条回复</span>
            </template>
            <t-form labelAlign="top" ref="form" class="step-form">
              <t-form-item name="content">
                <inner-html :content="data.contractExplain?.content"></inner-html>
              </t-form-item>
            </t-form>
          </t-card>
        </t-col>
      </t-row>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="11" label="附件信息">
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <t-table v-if="isMyProject" row-key="id" :columns="fileColumns" :data="fileData">
            <template #op="{ row }">
              <file-upload @success="uploadSuccess" tips="限制pdf、图片" accept="application/pdf,image/*"
                v-model="row.fileIds" :moduleKey="row.moduleKey" :fileList="row.fileLists" :multiple="true">
                <t-button variant="outline">
                  <t-icon name="cloud-upload" slot="icon" />
                  点击上传
                </t-button>
              </file-upload>
            </template>
            <template #c1="{ row }">
              <a v-if="row.c3" class="t-button-link" :href="`${file_domain}/${row.c3}`" target="_blank">{{ row.c1 }}</a>
              <div v-else>{{ row.c1 }}</div>
            </template>
          </t-table>
          <t-table v-else row-key="id" :columns="fileColumns" :data="fileData">
            <template #c1="{ row }">
              <a v-if="row.c3" class="t-button-link" :href="`${file_domain}/${row.c3}`" target="_blank">{{ row.c1 }}</a>
              <div v-else>{{ row.c1 }}</div>
            </template>
            <template #op="{ row }">
              <div v-for="(item, index) in row.fileLists" :key="index">
                <a class="t-button-link" target="_blank" :href="item.url">
                  {{ item.name }}
                </a>
              </div>
            </template>
          </t-table>
        </t-col>
      </t-row>
    </t-tab-panel>
    <t-tab-panel :class="[reviewOpen ? 'tab-full-panel' : 'tab-panel']" value="12" label="评审组信息">
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <expert-account-detail :projectName="header" :createUserId="this.rowByHttp.createUserId"
            :objId="objId"></expert-account-detail>
        </t-col>
      </t-row>
    </t-tab-panel>
  </t-tabs>
</template>

<script>
import { VITE_FILE_DOMAIN } from '@/api/upload'
import InnerHtml from "../../../../components/InnerHtml/index.vue";
import projectMember from "../../apply/components/project-member.vue";
import projectBudget from "../../apply/components/project-budget.vue";
import projectResearchPlan from "../../apply/components/project-research-plan.vue";
import projectKpi from "../../apply/components/project-kpi.vue";
import projectUnit from "../../apply/components/project-unit.vue";
import contractTerms from "./contract-terms.vue";
import approveListByReviewType from "../../approve/components/approve-list-by-review-type.vue";
import { getFiles } from "@/api/common";
import FileUpload from "@/components/FileUpload/index.vue";
import ExpertAccountDetail from "@/pages/kjxm/apply/components/expert-account-detail.vue";

export default {
  name: "contract-detail",
  dicts: ["subject_classification", "kjxm_team", "platform_type", "sys_user_sex", "prof_tit", "degree", "kjxm_key_word", "secret_level", "assume_company_type", "technosphere", "technology_source", "education"],
  components: {
    InnerHtml,
    projectMember,
    projectBudget,
    projectResearchPlan,
    projectKpi,
    projectUnit,
    contractTerms,
    approveListByReviewType,
    FileUpload,
    ExpertAccountDetail
  },
  props: {
    objId: [String, Number],
    row: Object,
    approveType: String,
    reviewOpen: {
      type: Boolean,
      default: false
    },
  },
  data () {
    return {
      value: "1",
      file_domain: VITE_FILE_DOMAIN,
      site_tag: import.meta.env.VITE_SITE_TAG,
      header: '',
      rowByHttp: {},
      isMyProject: false,
      fileData: [
        {
          id: 1,
          c1: "已盖章任务书",
          c2: "审批通过之后，走完盖章流程后上传。",
          fileIds: [],
          fileLists: [],
          moduleKey: "projectRWS"
        },
        {
          id: 2,
          c1: "其他附件",
          c2: "审批通过之后，走完盖章流程后上传。",
          fileIds: [],
          fileLists: [],
          moduleKey: "projectRWSQT"
        }
      ],
      fileColumns: [
        {
          colKey: "id",
          title: "序号",
          align: "center",
          width: 64
        },
        {
          colKey: "c1",
          title: "附件名称",
          align: "center",
        },

        {
          colKey: "c2",
          title: "是否必需",
          align: "center",
        },
        {
          colKey: "op",
          title: "附件列表",
          align: "left",
        },
      ],
      data: {
        projectName: '',
        secretLevel: '4',
        assumeCompanyType: '3',
        technosphere: '',
        technologySource: '',
        mainContent: '',
        expectResult: '',
        expectPatent: '',
        expectResultList: [],
        isSubmit: '',
        itemCompanyList: [],
        projectLeader: {},
        attributeDept: {},
        assumeDept: {},
        locationId: null,
        declareDeptName: this.$store.state.user.deptName,
        managerDeptId: null,
        managerDeptName: '',
        contractExpectResults: {
          awardsGjCount: 0,
          awardsSbCount: 0,
          cnThesisCount: 0,
          sciThesisCount: 0,
          eiThesisCount: 0,
          istpThesisCount: 0,
          treatiseCount: 0,
          academicCount: 0,
          pilotCount: 0,
          scaleCount: 0,
          patentFmCount: 0,
          patentSyCount: 0,
          otherCount: 0,
          standardCount: 0,
        },
        address: '',
        postCode: '',
        startDate: '',
        completeDate: '',
        projectId: null,
        adviceFunding: 0,
        subsidyFunding: 0,
        contractOverview: {},
        projectBudget: {},
        researchPlanList: [],
        expectResultsList: [],
        contractResults: [],
        projectCompanyList: [],
        projectMemberList: [],
        contractTerms: [],
        contractExplain: {}
      },
      projectData: {
        projectLeader: {}
      },
      locationOptions: [],
      categoryOptions: [],
      projectCategoryData: [],

    }
  },
  watch: {
    objId: {
      immediate: true,
      handler (val) {
        if (val) {
          this.getObj(val);
        }
      }
    },
  },
  created () {
    this.getLocationTree();
    this.getPlanCategoryList();
    if (!row) {
      this.$api.kjxm.contract.get(this.objId).then(res => {
        this.rowByHttp = res.data
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    } else {
      this.rowByHttp = this.row
    }
  },
  methods: {
    getObj () {
      // 获取项目附件
      getFiles(this.objId).then((res) => {
        const files = {}
        res.data.forEach((item) => {
          if (!files[item.moduleKey]) {
            files[item.moduleKey] = []
          }
          files[item.moduleKey].push({
            name: item.fileName,
            url: item.fullFilePath,
            id: item.id,
            filePath: item.filePath
          })
        })
        this.fileData.forEach((val,index)=>{
          this.fileData[index].fileLists = files[val.moduleKey] || [];
          this.fileData[index].fileIds = files[val.moduleKey]?.map(val => val.id) || [];
        })
        // this.fileData[0].fileLists = files.projectRWS || [];
        // this.fileData[0].fileIds = files.projectRWS?.map(val => val.id) || [];

      }).catch((e) => {
        this.$message.error(e.toString());
      });
      this.$api.kjxm.project.get(this.objId).then(pro => {
        this.projectData = pro.data;
      }).catch((e) => {
        this.applyLoading = false;
        this.$message.error(e.toString());
      });
      this.$api.kjxm.contract.getNewAll(this.objId).then(response => {
        if (response.data.createUserId === Number(this.$store.state.user.userId)) {
          this.isMyProject = true;
        }
        Object.assign(this.data, response.data);
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    getLocationTree () {
      return this.$api.system.location.treeselect().then(response => {
        this.locationOptions = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    getPlanCategoryList () {
      this.$api.kjxm.project.planCategoryList(this.queryParams).then(
        (res) => {
          let projectCategoryData = res.data.filter((val) => {
            if (!val.parentId) { return true }
          })
          this.projectCategoryData = projectCategoryData;
          this.categoryOptions = projectCategoryData.map((val) => ({ label: val.name, value: val.id }))
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
    },
    uploadSuccess (ids) {
      this.$api.kjxm.project.edit({
        id: this.objId,
        sysAttMainVo: {
          sysAttMainIds: ids,
        }
      }).then(val => {
        this.$message.success("上传成功");
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
  }
}
</script>

<style lang="less" scoped>
.t-tab-panel {
  padding: 10px;
}

.tab-panel {
  height: calc(65vh - 64px);
  overflow: scroll;
}

.tab-full-panel {
  height: calc(80vh - 64px);
  overflow: scroll;
}

.t-form__project {
  margin-bottom: 6px
}

.t-row {
  margin-bottom: 14px;
}

.step-card {
  margin-bottom: 14px;
}
</style>
